package com.xw.unification.test.controller;

import com.xw.unification.annotations.RequestRewrite;
import com.xw.unification.test.dto.AccountDTO;
import com.xw.unification.test.entity.AccountDTORewriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/rewrite")
public class RewriteController {

    private static final Logger LOGGER = LoggerFactory.getLogger(RewriteController.class);

    @PostMapping
    @RequestRewrite(rewriter = AccountDTORewriter.class)
    public String account(@RequestBody AccountDTO accountDTO) {
        LOGGER.info("account dto: {}", accountDTO);
        return "ok";
    }

}
